package zgame.main;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import zgame.bean.ChatRoom;
import zgame.bean.Friend;
import zgame.bean.Message;
import zgame.bean.ServerSessionStore;
import zgame.bean.Service;
import zgame.bean.Session;
import zgame.job.ReloadConfigJob;
import zgame.socket.client.ClientConnection;
import zgame.socket.handle.AuthenticateServiceHandle;
import zgame.socket.server.ServerConnection;

public class Global {
  public static final String AUTHENTICATE_SERVICE_ID = "1001";
  
  public static int RELOAD_CONFIG_INTERVAL; // ms
  
  public static int TIME_OUT;
  public static int HEART_BREATH_SEQUENCE_TIME;
  public static int DATA_UPDATE_SEQUENCE_TIME;

  //Constant for RequestManager
  public static int REQUEST_MANAGER_CORE_POLL_SIZE;
  public static int REQUEST_MANAGER_MAX_POLL_SIZE;
  public static int REQUEST_MANAGER_KEEP_ALIVE_TIME; // Minutes
  
  // Service info
  public static Service currentServiceInfo;
  public static Service defaultServiceInfo;
  
  // Job declare
  public static ReloadConfigJob reloadConfigJob = new ReloadConfigJob();
  
  // Chat bussiness data
  public static Map<String, ChatRoom> chatRooms = new HashMap<String, ChatRoom>();
  
  // Map to store message offline (key is toUser name)
  public static Map<String, Map<String, Message>> mesageOfflineStoreMap = new HashMap<String, Map<String, Message>>();
  
  // Danh sách các connection chưa xác nhận user
  public static List<ServerConnection> notAuthenConnectionList = new ArrayList<ServerConnection>();

  /** Lưu trữ các connection theo username */
  public static Map<String, ServerConnection> connectionMap = new HashMap<String, ServerConnection>(); // Key is username

  public static ClientConnection client;
  public static AuthenticateServiceHandle socketClientHandle = new AuthenticateServiceHandle();
  public static ServerListener serverListener = new ServerListener();

  public static Map<String, Map<String, Friend>> friendListCache = new HashMap<String, Map<String, Friend>>(); // Key is username

  /** Session map này chỉ dùng tạm để kiểm chứng sessionId của user chứ không để lưu trữ lâu dài */
  public static Map<String, Session> sessionMapTmp = new HashMap<String, Session>();
  public static Map<String, ServerSessionStore> encodedSessionFromClient = new HashMap<String, ServerSessionStore>();
}
